class listnode():
    def __init__(self,val=0,next=None):
        self.val=val
        self.next=next


def mergeTwoLists(list1 , list2):
    if (not list1 and not list2):
        return list1
    if (not list1 and list2):
        return list2
    if (list1 and not list2):
        return list1
    # list1和list2均不为零
    p1 = list1  # 链表的头节点
    p2 = list2
    result = None
    while (p1 and p2):
        if (p1.val >= p2.val):  # list2放前面
            if (not result):
                result = listnode(p2.val)
                # 截断，只保留list2的第一个节点
            else:
                p = result
                while (p.next):
                    p = p.next
                p.next = listnode(p2.val)
            p2 = p2.next
        else:
            if (not result):
                result = listnode(p1.val)
            else:
                p = result
                while (p.next):
                    p = p.next
                p.next = listnode(p1.val)
            p1 = p1.next
    if (not p1):  # 说明p2不为空，
        cur = result
        while (cur.next):
            cur = cur.next
        cur.next = p2
    if (not p2):  # 说明p2不为空，
        cur = result
        while (cur.next):
            cur = cur.next
        cur.next = p1
    return result
#
if __name__ == '__main__':
    l1=listnode(1)
    l1.next=listnode(2)
    l1.next.next=listnode(4)
    l2=listnode(1)
    l2.next=listnode(3)
    l2.next.next=listnode(4)
    l=mergeTwoLists(l1,l2)
    head=l
    while(l):
        print(l.val)
        l=l.next
    print("SSSSSSSSSSSSSSSSSSSSSSSSSSSss")
    p=head
    p.next.next.next.val=1000
    l=head
    while(l):
        print(l.val)
        l=l.next
    s='.222.222.222'
    print(s.split('.'))
    print('a30'>'a4')
    print(id(listnode(10)),id(listnode(10)))
    print( listnode(10) is  listnode(10))
    print( listnode(10) == listnode(10))
    a=listnode(10)
    print()